<?php
namespace model;

use think\Model;

class User extends Model{

    protected static function init(){
        User::event('after_insert', function ($user){
            $user->id && ($user->detail or UserDetail::create([
                'uid' => $user->id
            ]));
        });
    }

    public function detail(){
        return $this->hasOne('UserDetail', 'uid');
    }
}